#include "DM.h"
#include "parser_helper.h"
#include "message.h"
#include <string>

//----------------------------------------------------------------------------------------------------------//
PinNode_C::PinNode_C(string p_strNodeName,string p_strPinName,Inst_C* p_pInst,dir_E p_eDir) : 
    BoundaryNode_C(p_strNodeName), _strPinName(p_strPinName), _pInst(p_pInst), _eDir(p_eDir) 
{
}
//----------------------------------------------------------------------------------------------------------//
string PinNode_C::getFullName() const
{
    return _pInst->getName()+":"+_strPinName;
}
//----------------------------------------------------------------------------------------------------------//
string PinNode_C::getInstName() const
{
    return _pInst->getName();
}
//----------------------------------------------------------------------------------------------------------//
float PinNode_C::getPinCap() const
{
    LibCell_C* pLibCell = this->_pInst->getLibCell();
    float fPinCap = pLibCell->getCap(this->getPinName()); 
    return fPinCap;
}
//----------------------------------------------------------------------------------------------------------//
float PinNode_C::getNodeCap() const
{
    float fNodeCap = this->getParasiticCap() +this->getPinCap();
    return fNodeCap;
}
//----------------------------------------------------------------------------------------------------------//
void BoundaryNode_C::dumpTiming(Dumper* p_pDumper) const
{
    string name("");
    if(Node_C::ePin==this->getType()){
        char tmp[1024];
        strcpy(tmp,this->getName().c_str());
        char* pCh = strtok(tmp,":");
        name = pCh;
        name += "/";
        pCh = strtok(NULL,":");
        name += pCh;
    } else {
        name = this->getName().c_str();
    }
    p_pDumper->write("%s %.3f %.3f %.3f %.3f\n",
            //this->getInst()->getName().c_str(),this->getPinName().c_str(),
            name.c_str(),
            this->getTransRise(),this->getTransFall(),
            this->getDelayRise(),this->getDelayFall());
}
//----------------------------------------------------------------------------------------------------------//






